package tests;

import java.io.IOException;
import java.io.UnsupportedEncodingException;
import java.net.UnknownHostException;

import lib.Utility;
import lib.logging.ANSIConsoleLogger;
import lib.logging.ILogger;
import lib.messaging.Communicator;
import lib.messaging.ISender;
import lib.messaging.NetworkAddress;

/**
 * A test sender using ISender to send commands
 *
 * @author abhip
 *
 */
public class TestSenderProgram {
    public static void main(String args[]) throws UnknownHostException,
            IOException {
        ILogger logger = new ANSIConsoleLogger();

        try {
            String msg = "Hello Server! This is a message from client!";
            byte[] data = Utility.StringToByteArray(msg);

            ISender client = new Communicator(0.5f, logger);
            logger.LogInfo("Sending: " + msg);
            client.SendBytes(new NetworkAddress("localhost", 2012), data);
        } catch (UnsupportedEncodingException e) {
            logger.LogException(e);
        }
    }
}
